using System;
using System.Collections.Generic;
using System.Linq;
using YouFood.Web.Model;


namespace YouFood.Web
{
    public static class StatBussiness
    {

        public static YouFoodEntities context = new YouFoodEntities();

        public static IEnumerable<StatDto> GetStat()
        {
            var categoryCounts =
                from p in context.Orders
                group p by p.FoodReference.Value.Name into g
                select new StatDto { Name = g.Key, Count = g.Count() };

            return categoryCounts;
        }
    }
}